package com.yykj.drup.server.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @Author zeng
 * @Date 2022/3/17
 */
@ApiModel("处方药品信息")
@Data
public class PrescriptionProductDto {

    @ApiModelProperty(value = "药品主键ID",required = true)
    @NotNull(message = "药品主键ID: id")
    private Integer id;
    @ApiModelProperty("药品名称")
    private String title;
    @ApiModelProperty("药品用图")
    private String productImg;
    @ApiModelProperty("药品规格（西药）")
    private String skuName;
    @ApiModelProperty("药品用法（中药）")
    private String note;

    @NotNull(message = "药品数量: productNumber")
    @ApiModelProperty(value = "药品数量",required = true)
    private Integer productNumber;

    @ApiModelProperty("药品价格")
    private BigDecimal price;

    public void setProductNumber(Integer number){
        this.productNumber = number;
        if (price != null){
            this.price = this.price.multiply(new BigDecimal(number));
        }
    }
}

